﻿<template id="@(ViewBag.PageTemplate)">
    <div class="layout-page-content">
        <el-space fill style="width:100%">
            <el-input v-model="tableName" placeholder="请输入数据库表名，按回车后生成相应 Entity 代码" clearable v-on:keyup.enter.native="generate" v-on:clear="clear"></el-input>
            <el-input v-model="entityClassCode" readonly type="textarea" :autosize="{minRows:10}" resize="none"></el-input>
        </el-space>
    </div>
</template>
<script type="text/javascript">
    var @(ViewBag.PageName) = {
        template: "#@(ViewBag.PageTemplate)", data() {
            return {
                path: "@(ViewBag.PagePath)",
                tableName: null,
                entityClassCode: null
            }
        },
        methods: {
            generate(){
                var that = this;
                var tableName = that.tableName;
                if (tableName) {
                    that.entityClassCode = null;
                    app.func.getData(`${that.path}/generateentitycode`, { tableName }, ".layout-page-content", result => {
                        that.entityClassCode = result.data;
                    });
                }
                else { that.entityClassCode = null; }
            },
            clear(){
                this.entityClassCode = null;
            }
        },
        mounted() { }
    };
</script>